import request from "@/utils/request";

export const taskList = (params) => {
  return request({
    url: "/sysActing/list",
    method: "get",
    params,
  });
};
export const updateTask = (data) => {
  return request({
    url: "/sysActing/update",
    method: "post",
    data,
  });
};
export const remindList = (params) => {
  return request({
    url: "/sysRemind/list",
    method: "get",
    params,
  });
};
export const updateRemind = (data) => {
  return request({
    url: "/sysRemind/update",
    method: "post",
    data,
  });
};
export const geoserver = () => {
  return request({
    url: "/common/geoserver",
    method: "get",
  });
};
export const fxCount = () => {
  return request({
    url: "/preventionDevice/countByLevel",
    method: "get",
  });
};

export const downLoadFile = (url, name) => {
  if (url) {
    return request({
      method: "get",
      responseType: "blob",
      url: `/file/download?url=${url}`,
    }).then((res) => {
      const fileName = url.split("/");
      const blob = new Blob([res], {
        type: `application/.${res.type.toLowerCase()}`,
      });
      const link = document.createElement("a");
      link.href = window.URL.createObjectURL(blob);
      link.download = name || fileName[fileName.length - 1];
      link.click();
      link.remove();
    });
  }
};
// 首页统计接口
export const toCountQyKqZzSbRwYh = () => {
  return request({
    url: "/preventionPlanTask/toCountQyKqZzSbRwYh",
    method: "get",
  });
};

// 获取人员定位系统token
export const userLogin = () => {
  return request({
    url: "/common/userLogin",
    method: "get",
  });
};
